<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <base href="{$Think.const.BASE_PATH}">
    <title>VIP管理</title>
    <!--引入头部meta文件 -->
    {include file="./application/index/view/index/head_meta.html" /}
    <!--引入头部link(css)文件 -->
    {include file="./application/index/view/index/head_link.html" /}
    <!--引入头部script文件 -->
    {include file="./application/index/view/index/head_script.html" /}
    <link href="public/static/css/manager/vip_manager.css?v={$Think.const.NOW_TIME}" type="text/css" rel="stylesheet" />
</head>
<body>
<!--内容 START-->
{include file="manager/menu"/}
<div class="container">
    <div class="row">
        <div class="col-sm-3">
            <div class="row">
                <!--引入导航html文件 -->
                {include file="manager/navigate"/}
            </div>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="form-control ma-bottom" >
                 <label>可使用的卡号：  tips：以下为系统中未销售出去或者用户已经购买但未使用的卡密，请保证有剩余</label>
                </div>
                <table class="table table-bordered  table-striped">
                    <thead class="thead-light">
                    <tr>
                        <th>加油卡号</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="vip_codes" id="list"}
                        <tr>
                            <td>{$list.code}</td>
                        </tr>
                    {/volist}
                    </tbody>
                </table>
                <div class="form-control ma-bottom">
                    <label>一键生成加油卡号：</label>
                    <a class="btn" style="display: inline-block;" id="create_code">生成</a>
                    <label>
                        注意：以下生成的卡密请务必先填写到卡密代售服务商
                    </label>
                </div>
                <table class="table table-bordered  table-striped">
                    <thead class="thead-light">
                    <tr>
                        <th>加油卡号</th>
                    </tr>
                    </thead>
                    <tbody id="create_code_new"></tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<!--内容 END-->

<script type="text/javascript">
    $(function () {
        $("#create_code").click(function () {
            $.ajax({
                url:"{:url('manager/create_vip_code')}",
                type:"POST",
                dataType:"json",
                data:{
                    num:5
                },
                success:function (data) {
                    if(data.code=="1"){
                        alert("生成加油卡成功，请填写到卡密代售服务商");
                        for(var i=0;i<data.data.length;i++){
                            var html = [];
                            html.push("<tr>");
                            html.push("<td>");
                            html.push(data.data[i].code);
                            html.push("</td>");
                            html.push("</tr>");
                            $("#create_code_new").append(html.join(''));
                        }

                    }else{
                        alert("生成加油卡失败！加油卡号不存在");
                    }
                }
            });
        });
    })
</script>
</body>
</html>